<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="managesystem.Student" %>
<%@ page import="tracksystem.SchoolActivity" %>
<%@ page import="tracksystem.OtherActivity" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<html> 
   <head>
      <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
      <title>Account ||Activities</title> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
      <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
      <script src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
	  
	  
      <%
      	session.setAttribute("fromMobile","true");
   		Student currStud = (Student) session.getAttribute("currStud");
  		if(currStud == null){
  			response.sendRedirect("../index-mobile.jsp");
  		}
  		List<SchoolActivity> schoolActs = currStud.getOnlySchoolActs();
  		List<OtherActivity> otherActs = currStud.getOnlyOtherActs();
   	  %>
   </head> 
	<body> 
		<div data-role="page" id="tools">
						<div data-role="header" data-theme="b">
							<h1>Account || Activities</h1>
							<a href="/index-mobile.jsp" data-icon="home" data-ajax="false" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Home</a>
							<a href="/mobile-inc/track.jsp" data-icon="plus" class="ui-btn-right" data-ajax="false">New Activity</a>
						</div>
					
						<div data-role="content" data-theme="b">
							
							<%
								String msg = (String) session.getAttribute("message");
								session.setAttribute("message",null);
								if(msg != null){
									%>
										<p style="color:green;"><%=msg %></p>
									<%
								}
									
								
								if(schoolActs.size() !=0){
								%>
									<ul data-role="listview">
								<li data-role="list-divider" data-theme="a">SchoolActivities <span class="ui-li-count"><%=schoolActs.size() %></span></li>
								<%
							  	for(SchoolActivity sa : schoolActs){
							  		Long duration = sa.getDuration();
							  				Long hours = duration / (1000*60*60);
							  				Long minutes = (duration % (1000*60*60)) / (1000*60);
							  				
							  		%>	
							  			
							  				<li>								
													<h3><%=sa.getCourse().getName() %></h3>	
																				
													<p><strong><%=sa.getDescription() %></strong></p>
													<p>Time spent : <%=hours%> hours and <%=minutes %> minutes</p>
													<p class="ui-li-aside"><strong>Prof. </strong><%=sa.getCourse().getProf() %></p>
													<p class="ui-li-aside"><strong>Type: </strong><%=sa.getType() %></p>
											</li>
							  			
							  		<%
							  	}
								%></ul><%
								}else{
								%>
									<p style="color:red;">No school activities are tracked.</p>
								<%
								}
								if(otherActs.size() !=0){
									%>
									<ul data-role="listview">
								<li data-role="list-divider" data-theme="a">Other activities <span class="ui-li-count"><%=otherActs.size() %></span></li>
								<%
							  	for(OtherActivity oa : otherActs){
							  		Long duration = oa.getDuration();
							  				Long hours = duration / (1000*60*60);
							  				Long minutes = (duration % (1000*60*60)) / (1000*60);
							  				
							  		%>	
							  			
							  				<li>								
													<h3><%=oa.getType() %></h3>	
																				
													<p><strong><%=oa.getDescription() %></strong></p>
													<p>Time spent : <%=hours %> hours and <%=minutes %> minutes</p>
											</li>
							  			
							  		<%							
									}%></ul>
									<%}else{
										%>
										<p style="color:red;">No other activities are tracked.</p>
									<%
								}
							%>
							
						</div>
						<div data-role="footer" data-theme="b">
							<p align="center">Logged in as : <%=currStud.getUsername()%></p>
						</div>
				  	</div>
	</body>
</html>